package com.soup.lab.junit5;

import org.junit.jupiter.api.*;
import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;

@SpringBootTest
public class LifeCycleTestCase {

    @Autowired
    private TestComponent testComponent;

    @BeforeAll
    public static void beforeAll() {
        System.out.println("beforeAll");
    }

    /**
        在执行成员方法前，spring容器才进行初始化
        {@link TestMethodTestDescriptor#prepare}
        {@link DependencyInjectionTestExecutionListener#prepareTestInstance}
     */

    @BeforeEach
    public void beforeEach() {
        System.out.println("beforeEach:"+ testComponent);
    }

    @Test
    public void test() {
        System.out.println("test:"+ testComponent);
    }

    @AfterEach
    public void afterEach() {
        System.out.println("afterEach:"+ testComponent);
    }

    @AfterAll
    public static void AfterAll() {
        System.out.println("AfterAll");
    }

}
